Swing High/Low Indicator w/ MACD and HTF EMA'sSwing High/Low Indicator w/ MACD and EMA Confirmations by KaizenTraderB
I designed this indicator to be used with a market structure break strategy.
It labels swing highs and lows that are confirmed by the MACD.
It also displays a higher timeframe Fast and Slow EMA to determine directional bias.
Also provides alerts that signal Swing Low breaks in downtrends and Swing High Breaks in uptrends.
It draws a horizontal line on the last Swing High and Low.
Display this indicator on your entry timeframe and choose your Higher Timeframe in settings.
You can also change lookback period for Swing Highs and Lows and EMA's.
When I use this I am looking for the Swing High/Low break in direction of HTF Trend
Then look for pullback between price level of break and areas of liquidity (wicks, order blocks, price congestion) for entry in direction of EMA trend.
Cerca negli script per "swing high low"
Swing High/Low SignalsSwing High/Low Signals – profit gang
Quickly spot recent market turning points with this clean swing high/low indicator.
Marks swing highs & lows with labels or triangles
Optional connecting lines & background highlights
Alerts when new swings form
Info table showing last swing levels & current price
Fully adjustable lookback period for any timeframe.
Disclaimer: For educational use only. Not financial advice.
Swing High/Low (ZigZag) [ChartPrime]Swing High/Low (ZigZag) Indicator
The Swing High/Low (ZigZag) Indicator is a versatile tool for identifying and visualizing price swings, swing highs, and swing lows. It dynamically plots levels for significant price points while connecting them with a ZigZag line, enabling traders to analyze market structure and trends with precision.
⯁ KEY FEATURES
Swing Highs and Lows Detection
Accurately detects and marks swing highs and lows, providing a clear structure of market movements.
Real-Time ZigZag Line
Connects swing points with a dynamic ZigZag line for a visual representation of price trends.
Customizable Swing Sensitivity
Swing length input allows traders to adjust the sensitivity of swing detection to match their preferred market conditions.
Swing Levels with Shadows
Option to display swing levels with extended shadows for better visibility and market analysis.
Broken Levels Marking
Tracks and visually updates levels as dashed lines when broken, providing insights into shifts in market structure.
Swing Direction Display
At the top-right corner, the indicator displays the current swing direction (up or down) with a directional arrow for quick reference.
Interactive Labels
Marks swing levels with labels, showing the price of swing highs and lows for added clarity.
Dynamic Market Structure Analysis
Automatically adjusts ZigZag lines and levels as the market evolves, ensuring real-time updates for accurate trading decisions.
⯁ HOW TO USE
Analyze Market Trends
Use the ZigZag line and swing levels to identify the overall direction and structure of the market.
Spot Significant Price Points
Swing highs and lows act as potential support and resistance levels for trading opportunities.
Adjust Swing Sensitivity
Modify the swing length setting to match your trading strategy, whether scalping, day trading, or swing trading.
Monitor Broken Levels
Use the dashed lines of broken levels to identify changes in market dynamics and potential breakout or breakdown zones.
Plan Entries and Exits
Leverage swing levels and direction to determine optimal entry, stop-loss, and take-profit points.
⯁ CONCLUSION
The Swing High/Low (ZigZag) Indicator is a powerful tool for traders seeking to visualize price swings and market structure. Its real-time updates, customizable settings, and dynamic swing direction make it an invaluable resource for technical analysis and decision-making.
Swing High/Low & EMA Cross AlertScript Description:
This script on TradingView combines the detection of Swing High/Low points with exponential moving average (EMA) crossovers to provide buy and sell alerts and to mark swing points on the chart.
What the Script Does:
Swing High/Low Detection:
Uses the ta.pivothigh function to detect significant high points and the ta.pivotlow function to detect significant low points.
For each detected point, the script checks if it is a new higher high (HH) or lower high (LH) for the highs, and a new lower low (LL) or higher low (HL) for the lows.
Creates visual labels to identify these points on the chart, helping traders to visualize potential reversal points.
EMA Crossover:
Calculates two EMAs: a fast EMA (fastEMA) with a default period of 50 and a slow EMA (slowEMA) with a default period of 200.
Detects bullish crossovers (when fastEMA crosses above slowEMA) and bearish crossunders (when fastEMA crosses below slowEMA).
Generates buy and sell alerts based on these crossovers.
How the Script Works:
EMA Calculation: EMAs are calculated using the closing prices and user-defined periods.
Swing High/Low Detection: Uses the high and low values from the previous length bars to determine the swing points.
Alert Generation: Alerts are triggered when crossovers between the EMAs occur.
How to Use the Script:
Add to Chart: Insert the script into TradingView and apply it to the desired chart.
Configure Parameters:
Adjust the detection period for swing points (length).
Configure the periods for the EMAs (fastLen and slowLen).
Customize the colors for the swing point labels as per your preference.
Monitor Alerts: Use the EMA crossover alerts to make buy or sell decisions. Observe the swing point labels to identify potential trend reversals.
Justification for the Combination:
EMAs: Widely used to identify trend direction. Combining a fast EMA with a slow EMA helps capture both short-term and long-term trend changes.
Swing High/Low: Identifies reversal points in price, which are crucial for determining potential entry and exit points in trades.
Combination:
Combining EMAs and Swing High/Low provides a comprehensive view of price behavior, helping traders to effectively identify trends and reversal points.
This script is useful for traders who want to combine trend analysis (via EMAs) with the identification of reversal points (Swing High/Low), providing a more complete view of price behavior on the chart.
Swing High Low Detector by RV5📄 Description
The Swing High Low Detector is a visual indicator that automatically detects and displays swing highs and swing lows on the chart. Swings are determined based on configurable strength parameters (number of bars before and after a high/low), allowing users to fine-tune the sensitivity of the swing points.
🔹 Current swing levels are shown as solid (or user-defined) lines that dynamically extend until broken.
🔹 Past swing levels are preserved as dashed/dotted lines once broken, allowing traders to see previous support/resistance zones.
🔹 Customizable line colors, styles, and thickness for both current and past levels.
This indicator is useful for:
Identifying key market structure turning points
Building breakout strategies
Spotting trend reversals and swing zones
⚙️ How to Use
1. Add the indicator to any chart on any timeframe.
2. Adjust the Swing Strength inputs to change how sensitive the detector is:
A higher value will filter out smaller moves.
A lower value will capture more frequent swing points.
3. Customize the line styles for visual preference.
Choose different colors, line styles (solid/dashed/dotted), and thickness for:
Current Swing Highs (SH)
Past Swing Highs
Current Swing Lows (SL)
Past Swing Lows
4. Observe:
As new swing highs/lows are detected, the indicator draws a new current level.
Once price breaks that level, the line is archived as a past level and a new current swing is drawn.
✅ Features
Fully customizable styling for all lines
Real-time updates and automatic level tracking
Supports all chart types and instruments
👨💻 Credits
Script logic and implementation by RV5. This script was developed as a tool to improve price action visualization and trading structure clarity. Not affiliated with any financial institution. Use responsibly.
Swing High/Low by %REnglish Description
Swing High/Low by %R
This indicator identifies potential swing high and swing low points by combining William %R overbought/oversold turning points with classic swing price structures.
Swing High: Detected when William %R turns down from overbought territory and the price forms a local high (higher than both neighboring bars).
Swing Low: Detected when William %R turns up from oversold territory and the price forms a local low (lower than both neighboring bars).
This tool is designed to help traders spot possible market reversals and better time their entries and exits.
Customizable parameters:
Williams %R period
Overbought & Oversold thresholds
The indicator plots clear signals above/below price bars for easy visualization.
For educational purposes. Please use with proper risk management!
คำอธิบายภาษาไทย
Swing High/Low by %R
อินดิเคเตอร์นี้ใช้ระบุจุด Swing High และ Swing Low ที่มีโอกาสเป็นจุดกลับตัวของตลาด โดยอาศัยสัญญาณจาก William %R ที่พลิกกลับตัวบริเวณ overbought/oversold ร่วมกับโครงสร้างราคาแบบ swing
Swing High: เกิดเมื่อ William %R พลิกกลับลงจากเขต Overbought และราคาแท่งกลางสูงกว่าทั้งสองแท่งข้างเคียง
Swing Low: เกิดเมื่อ William %R พลิกกลับขึ้นจากเขต Oversold และราคาแท่งกลางต่ำกว่าทั้งสองแท่งข้างเคียง
ช่วยให้เทรดเดอร์สามารถมองเห็นโอกาสในการกลับตัวของราคา และใช้ประกอบการวางแผนจังหวะเข้าหรือออกจากตลาดได้อย่างแม่นยำมากขึ้น
ตั้งค่าได้:
ระยะเวลา Williams %R
ค่าขอบเขต Overbought & Oversold
อินดิเคเตอร์จะแสดงสัญลักษณ์อย่างชัดเจนบนกราฟเพื่อความสะดวกในการใช้งาน
ควรใช้ร่วมกับการบริหารความเสี่ยง
Swing Highs/Lows & Candle Patterns [LuxAlgo]This script labels swing highs and swing lows as well as the candle pattern that occurred at that precise point. The script can detect the following 6 candle patterns: hammer, inverse hammer, bullish engulfing, hanging man, shooting star, and bearish engulfing.
This indicator by its very nature backpaints by default, meaning that the displayed components are offset in the past.
🔶 USAGE
It can be interesting to see if a top or bottom is associated with a specific candle pattern, this allows us to study the potential of such a pattern to indicate a reversal. You can hover on a label with a specific pattern to see more details about it.
The notations HH, HL, LH, and LL you can see on the labels are defined as follows:
HH : Higher high
HL : Higher low
LH : Lower high
LL : Lower low
🔶 SETTING
Length: Sensitivity of the swing high/low detection, with lower values returning the maximum/minimum of shorter-term price variations.
Swing High/Low Pivots Strategy [LV]The Swing High/Low Pivots Strategy was developed as a counter-momentum trading tool.
The strategy is suitable for any market and the default values used in the input settings menu are set for Bitcoin (best on 15min). These values, expressed in minimum ticks (or pips if symbol is Forex) make this tool perfectly adaptable to every symbol and/or timeframe.
Check tooltips in the settings menu for more details about every user input.
STRTEGY ENTRY & EXIT MECHANISMS:
Trades Entry based on the detection of swing highs and lows for short and long entries respectively, validated by:
- Limit orders placed after each new pivot level confirmation
- Moving averages trend filter (if enabled)
- No active trade currently open
Trades Exit when the price reaches take-profit or stop-loss level as defined in the settings menu. A double entry/second take-profit level can be enabled for partial exits, with dynamic stop-loss adjustment for the remaining position.
Enhanced Trade Precision:
By limiting entries to confirmed swing high (HH, LH) or swing low (HL, LL) pivot points, the strategy ensures that trades occur at levels of significant price reversals. This precision reduces the likelihood of entering trades in the midst of a trend or during uncertain price action.
Risk Management Optimization:
The strategy incorporates clearly defined stop-loss (SL) and take-profit (TP) levels derived from the pivot points. This structured approach minimizes potential losses while locking in profits, which is critical for consistent performance in volatile markets.
Trend Filtering for Better Entry:
The use of a configurable moving average filter adds a layer of trend validation. This prevents entering trades against the dominant market trend, increasing the probability of success for each trade.
Avoidance of Noise:
The lookback period (length parameter) confirms pivots only after a set number of bars, effectively filtering out market noise and ensuring that entries are based on reliable, well-defined price movements.
Adaptability Across Markets:
The strategy is versatile and can be applied across different markets (Forex, stocks, crypto) due to its dynamic use of ticks and pips converters. It adapts seamlessly to varying price scales and asset types.
Dual Quantity Entries:
The original and optionnal double-entry mechanism allows traders to capture both short-term and extended profits by scaling out of positions. This adaptive approach caters to varying risk appetites and market conditions.
Clear Visualization:
The plotted pivot points, entry limits, SL, and TP levels provide visual clarity, making it easy for traders to track the strategy's behavior and make informed decisions.
Automated Execution with Alerts:
Integrated alerts for both entries and exits ensure timely actions without the need for constant market monitoring, enhancing efficiency. Configurable alert messages are suitable for API use.
Any feedback, comments, or suggestions for improvement are always welcome.
Hope you enjoy!
Swing High/Low Anchored SpiralFit the estimate of an Archimedean spiral to the price, with a central point determined by swing high/lows.
Users can determine which historical swing high/low to use as the spiral central point and can choose the number of turns it should make.
You can create cool shapes, cool enough to satisfy your apophenia needs.
If you are having issues just hide and unhide the script, or just lower the length/occurrence setting.
Posting is impossible without the support of my Patreons as well as @LuxAlgo, my scripts are dedicated to them.
TR FVG & Swing High Low FinderTR FVG & Swing Level Finder
Overview:
The TR FVG & Swing Level Finder is a powerful Pine Script indicator designed for traders who want to identify Fair Value Gaps (FVGs) and Swing Highs/Lows on their charts. This indicator combines two essential technical analysis tools into one, helping traders spot potential areas of support, resistance, and trend reversals. FVGs are price gaps that often act as areas of interest for price to return to, while swing highs and lows help identify key turning points in the market. The indicator is highly customizable, allowing users to adjust colors, limits, and display options to suit their trading style.
Key Features:
1: Fair Value Gap (FVG) Detection:
- Identifies Bullish FVGs: Occur when the high of two candles ago is lower than the low of the current candle, indicating a potential upward price movement.
- Identifies Bearish FVGs: Occur when the low of two candles ago is higher than the high of the current candle, indicating a potential downward price movement.
- Displays FVGs as colored boxes on the chart, with customizable border and fill colors based on the timeframe.
- Labels each FVG box with the corresponding timeframe (e.g., "1m FVG", "1h FVG", "Daily FVG").
2: Swing High and Swing Low Detection:
- Detects Swing Highs: A 3-candle pattern where the middle candle's high is higher than the highs of the candles on either side.
- Detects Swing Lows: A 3-candle pattern where the middle candle's low is lower than the lows of the candles on either side.
- Draws a solid black line with 50% opacity at each swing high and low, extending 5 bars to the right for better visibility.
- Adds a small Swing High or Swing Low label at the right end of each line, colored according to user-defined settings.
3: Timeframe-Specific FVG Visualization:
- FVGs are color-coded based on the chart's timeframe, making it easy to distinguish between FVGs on different timeframes.
- Each timeframe has its own fill color for bullish and bearish FVGs, with adjustable transparency for better chart clarity.
- A dashed black line is drawn in the middle of each FVG box to highlight the midpoint of the gap.
4: Customizable Display Options:
- FVG Limit: Control the maximum number of FVGs displayed on the chart (from 1 to 20).
- Extend Options for FVG Boxes:
- "None": FVG boxes extend only 2 bars to the right.
- "Limited": FVG boxes extend a user-defined number of candles to the right (1 to 100 candles).
- "Default": FVG boxes extend 3 bars to the right of the current bar.
- Color Customization:
- Set border colors for bullish and bearish FVGs.
- Adjust fill colors for FVGs on different timeframes (1m, 5m, 15m, 30m, 1h, 4h, Daily, Weekly, Monthly).
- Customize the colors of swing high and swing low labels.
5: Performance Optimization:
- The indicator only plots FVGs and swings on the last confirmed bar (barstate.islastconfirmedhistory), ensuring efficient performance and reducing chart clutter.
- Limits the number of displayed FVGs and swings to the user-defined fvgLimit, keeping the chart clean and focused on the most recent price action.
6: Inputs and Customization:
- Number of FVGs to Show (fvgLimit): Set the maximum number of FVGs and swings to display (default: 3, range: 1 to 20).
- Bullish FVG Border Color (bullishColor): Choose the border color for bullish FVGs (default: green).
- Bearish FVG Border Color (bearishColor): Choose the border color for bearish FVGs (default: red).
- Swing High Color (swingHighColor): Set the color for swing high labels (default: blue).
- Swing Low Color (swingLowColor): Set the color for swing low labels (default: purple).
- Extend Options:
- Extend Option (extendOption): Choose how far FVG boxes extend to the right ("None", "Limited", or "Default"; default: "Default").
- Extend Candles (extendCandles): If "Limited" is selected, specify the number of candles to extend FVG boxes (default: 8, range: 1 to 100).
- Timeframe-Specific Fill Colors:
- Customize fill colors for bullish and bearish FVGs on various timeframes (1m, 5m, 15m, 30m, 1h, 4h, Daily, Weekly, Monthly).
- Each fill color has a default transparency (e.g., 93% for most timeframes, 90% for 30m), which can be adjusted as needed.
How to Use:
1: Add the Indicator to Your Chart:
- Open TradingView, go to the Pine Editor, and paste the script.
- Click "Add to Chart" to apply the indicator to your current chart.
2: Adjust Settings:
- Open the indicator settings by clicking the gear icon next to the indicator name on your chart.
- Modify the inputs to suit your preferences:
- Set the number of FVGs and swings to display.
- Choose your preferred colors for FVGs and swings.
- Adjust the extend options for FVG boxes.
3: Interpret the Indicator:
- FVG Boxes: Look for colored boxes on the chart, which represent Fair Value Gaps. Bullish FVGs (green borders by default) suggest potential buying opportunities, while bearish FVGs (red borders by default) suggest potential selling opportunities. The label inside each box indicates the timeframe of the FVG.
- Swing Highs and Lows: Identify key turning points with solid black lines (50% opacity) at swing highs and lows. Each line extends 5 bars to the right, with an "SH" (Swing High) or "SL" (Swing Low) label at the end. Swing highs can act as resistance levels, while swing lows can act as support levels.
4: Combine with Your Strategy:
- Use FVGs to identify areas where price might return to fill the gap, often acting as support or resistance.
- Use swing highs and lows to spot potential trend reversals or to set stop-loss and take-profit levels.
- Combine the indicator with other tools (e.g., trendlines, moving averages) for a more comprehensive trading strategy.
Notes:
- The indicator works on all timeframes, but the appearance of FVGs and swings will vary depending on the chart's timeframe.
- For best results, use the indicator on a clean chart to avoid visual clutter, especially if you increase the fvgLimit.
- The swing high/low lines are drawn with 50% opacity to ensure they don’t overpower other chart elements, but they are still clearly visible.
Author’s Note:
This script was developed to help traders identify key price levels with ease. I hope it adds value to your trading! If you have any feedback or suggestions for improvement, feel free to leave a comment. Happy trading!
Heikin Ashi & Swing Highs/LowsHeikin Ashi & Swing Highs/Lows
Indicator Description:
The "Heikin Ashi & Swing Highs/Lows" indicator combines Heikin Ashi candle analysis with the identification of significant swing highs and lows on the chart. This indicator is useful for traders looking to spot trend changes and key points in the market.
Key Features:
Heikin Ashi:
Calculation and Visualization: Utilizes the Heikin Ashi method to smooth out the candlestick chart, helping to visualize trends and reduce market noise. Heikin Ashi candles are calculated from the standard candles (Open, High, Low, Close) and are displayed on the chart with a green color for bullish signals and red for bearish signals.
Vertical Offset Adjustment: Provides options to adjust the vertical offset of the candles based on the selected timeframe, with specific adjustments for short, medium, long, and super-long periods.
Swing Highs/Lows:
Key Point Identification: Marks significant swing highs and lows on the chart using a configurable period. Swing highs are displayed in red and swing lows in green.
Candlestick Patterns: Detects and labels common candlestick patterns such as:
Hammer: A bullish candlestick pattern with a small body and a long lower wick.
Inverted Hammer: Similar to the Hammer, but with a long upper wick.
Bullish Engulfing: A two-candle pattern where a bullish candle completely engulfs a previous bearish candle.
Hanging Man: A bearish pattern with a small body and a long lower wick, appearing at the end of an uptrend.
Shooting Star: A bearish pattern with a small body and a long upper wick, appearing at the end of an uptrend.
Bearish Engulfing: A two-candle pattern where a bearish candle completely engulfs a previous bullish candle.
Settings:
Timeframe: Allows you to select the desired timeframe to adjust the Heikin Ashi candle analysis.
Vertical Offset: Customize the vertical offset of Heikin Ashi candles based on the selected timeframe.
Swing Point Style: Configure the colors of the significant swing highs and lows on the chart.
Recommended Use:
This indicator is ideal for traders looking for a clear representation of trends through Heikin Ashi candles and who want to identify key reversal points in the market by detecting swing highs/lows and candlestick patterns.
Benefits:
Facilitates the identification of smooth trends and trend reversals.
Provides a clear visual representation of critical market points.
Helps traders recognize important candlestick patterns that may indicate changes in market direction.
Intraday CPR with Previous Highs and Lows and Swing Highs/LowsThis Pine Script indicator plots the Central Pivot Range (CPR) for the current trading day along with previous day's high (PDH), low (PDL), and swing high/low (Swing H/L) values. It also includes the high, low, and swing high/low values from two days back for reference.
Key Features:
Central Pivot Range (CPR):
Pivot Point (PP): The central pivot point.
Bottom Central Pivot (BC): The lower boundary of the CPR.
Top Central Pivot (TC): The upper boundary of the CPR.
The area between the BC and TC is shaded for better visualization.
Previous Day and Two Days Back Values:
Previous Day High (PDH) and Low (PDL): Plots the high and low of the previous trading day.
Two Days Back High and Low: Plots the high and low from two trading days ago.
Previous Day Swing High/Low: The highest high and lowest low from a specified period (swing period) of the previous trading day.
Two Days Back Swing High/Low: The highest high and lowest low from a specified period (swing period) of two trading days ago.
Historical Swing High-Low Gann IndicatorThe Historical Swing High-Low Gann Indicator is a powerful tool designed to track and visualize key market swing points over time. This indicator identifies significant swing highs and lows within a specified time frame and draws connecting lines between these points, allowing traders to observe the natural ebb and flow of the market.
What sets this indicator apart is its ability to maintain all previously drawn swing lines, creating a comprehensive historical view of market movements. Additionally, the indicator projects Gann-style lines from the most recent swing highs and lows, providing traders with potential future support and resistance levels based on the geometric progression of price action.
Features:
Swing Detection: Automatically detects significant swing highs and lows over a user-defined period (default is 3 hours).
Persistent Historical Lines: Keeps all previously drawn lines, offering a complete visual history of the market's swing points.
Gann-Style Projections: Draws forward-looking lines from the latest swing points to help predict possible future market levels.
Customizable Parameters: Allows users to adjust the swing detection period to suit different trading styles and time frames.
This indicator is ideal for traders who rely on price action, support and resistance levels, and Gann theory for their analysis. Whether used in isolation or as part of a broader strategy, the Historical Swing High-Low Gann Indicator provides valuable insights into the market's behavior over time.
Advanced Swing High/Low Trend Lines with MA Filter# Advanced Swing High/Low Trend Lines Indicator
## Overview
This advanced indicator identifies and draws trend lines based on swing highs and lows across three different timeframes (large, middle, and small trends). It's designed to help traders visualize market structure and potential support/resistance levels at multiple scales simultaneously.
## Key Features
- *Multi-Timeframe Analysis*: Simultaneously tracks trends at large (200-bar), middle (100-bar), and small (50-bar) scales
- *Customizable Visualization*: Different colors, widths, and styles for each trend level
- *Trend Confirmation System*: Requires minimum consecutive pivot points to validate trends
- *Trend Filter Option*: Can align trends with 200 EMA direction for consistency
## Recommended Settings
### For Long-Term Investors:
- Large Swing Length: 200-300
- Middle Swing Length: 100-150
- Small Swing Length: 50-75
- Enable Trend Filter: Yes
- Confirmation Points: 4-5
### For Swing Traders:
- Large Swing Length: 100
- Middle Swing Length: 50
- Small Swing Length: 20-30
- Enable Trend Filter: Optional
- Confirmation Points: 3
### For Day Traders:
- Large Swing Length: 50
- Middle Swing Length: 20
- Small Swing Length: 5-10
- Enable Trend Filter: No
- Confirmation Points: 2-3
## How to Use
### Identification:
1. *Large Trend Lines* (Red/Green): Show major market structure
2. *Middle Trend Lines* (Purple/Aqua): Intermediate levels
3. *Small Trend Lines* (Orange/Blue): Short-term price action
### Trading Applications:
- *Breakout Trading*: Watch for price breaking through multiple trend lines
- *Bounce Trading*: Look for reactions at confluence of trend lines
- *Trend Confirmation*: Aligned trends across timeframes suggest stronger moves
### Best Markets:
- Works well in trending markets (forex, indices)
- Effective in higher timeframes (1H+)
- Can be used in ranging markets to identify boundaries
## Customization Tips
1. For cleaner charts, reduce line widths in congested markets
2. Use dotted styles for smaller trends to reduce visual clutter
3. Adjust confirmation points based on market volatility (higher for noisy markets)
## Limitations
- May repaint on current swing points
- Works best in trending conditions
- Requires sufficient historical data for longer swing lengths
This indicator provides a comprehensive view of market structure across multiple timeframes, helping traders make more informed decisions by visualizing the hierarchy of support and resistance levels.
CM Gann Swing High Low V2CM Gann Swing High Low V2
Added Improvements:
Used PineScript “linebr" code so solid lines plot only when condition = true.
Via Inputs Tab:
Ability to Turn On/Off Highlight Bars When Crossing Above/Below Swing High Low
Ability to Turn On/Off Back Ground Highlights When Crossing Above/Below Swing High Low
Ability to Turn On/Off linebr plots.
Other Features: All Available Via Inputs Tab
Ability to Adjust Moving Average Values to adjust Sensitivity.
Ability to Turn On/Off Triangles Above/Below Bars based on Indicator.
Ability to Turn On/Off Triangles at Top And Bottom Of Screen Showing Direction of Indicator.
***Basically you have Option to View Indicator about every way possible.
***Special Thanks to Glaz for Original Code.
Heiken Ashi Swing High/LowIt uses Heiken Ashi candles to detect recent swing high and low.
It can be used as a stop-loss or support/resistance indicator.
Swing High/Low with Liquidity Sweeps🧠 Overview
This indicator identifies swing highs and swing lows based on user-defined candle lengths and checks for liquidity sweeps—situations where the price breaks a previous swing level but then closes back inside, indicating a potential false breakout or stop hunt. It also supports visual labeling and alerts for these events.
⚙️ Inputs
Swing Length (must be odd number ≥ 3):
Determines how many candles are used to identify swing highs/lows. The central candle must be higher or lower than all neighbors within the range.
Example: If swingLength = 5, the central candle must be higher/lower than the 2 candles on both sides.
Sweep Lookback (bars):
Defines how many bars to look back for possible liquidity sweeps.
Show Swing Labels (checkbox):
Optionally display labels on the chart when a swing high or low is detected.
Show Sweep Labels (checkbox):
Optionally display labels on the chart when a liquidity sweep occurs.
🕯️ Swing Detection Logic
A Swing High is detected when the high of the central candle is greater than the highs of all candles around it (as per the defined length).
A Swing Low is detected when the low of the central candle is lower than the lows of surrounding candles.
Swing labels are placed slightly above (for highs) or below (for lows) the candle.
💧 Liquidity Sweep Logic
A Sweep High is triggered if:
The current high breaks above a previously detected swing high,
And then the candle closes below that swing high,
Within the configured lookback window.
A Sweep Low is triggered if:
The current low breaks below a previous swing low,
And then closes above it,
Within the lookback window.
These are often seen as stop hunts or fake breakouts.
🔔 Alerts
Sweep High Alert: Triggered when a sweep above a swing high occurs.
Sweep Low Alert: Triggered when a sweep below a swing low occurs.
You can use these to set up TradingView alerts to notify you of potential liquidity grabs.
📊 Use Cases
Identifying market structure shifts.
Spotting fake breakouts and potential reversals.
Assisting in smart money concepts and liquidity-based trading.
Supporting entry timing in trend continuation or reversal strategies.
Swing High/LowPlots the swing high and low points based on user configurable look back settings. Also allows you to plot the most recent swing low as a horizontal line for obvious stop point on long setups.
Swings High Low with dates BY CheI share this simple indicator for free.
The indicator consists of marking the most important swings, either high or low.
So you can analyze how the price interacts in the future with these values.
The original code belongs to another author.
I added the possibility to filter swings between dates, this way only the swings we are interested in between those dates are marked.
Feel free to share and copy this script!
Enjoy!
Swing High Low Price Channel V.1You should buy/sell small order at small plot zone or after small plot. And, Buy/sell big order at big plot zone or after big plot.
Recommended, You should use this with Fibonacci Retracement, Price Action or Graph Pattern.
SMC Structures and FVGสวัสดีครับ! ผมจะอธิบายอินดิเคเตอร์ "SMC Structures and FVG + MACD" ที่คุณให้มาอย่างละเอียดในแต่ละส่วน เพื่อให้คุณเข้าใจการทำงานของมันอย่างถ่องแท้ครับ
อินดิเคเตอร์นี้เป็นการผสมผสานแนวคิดของ Smart Money Concept (SMC) ซึ่งเน้นการวิเคราะห์โครงสร้างตลาด (Market Structure) และ Fair Value Gap (FVG) เข้ากับอินดิเคเตอร์ MACD เพื่อใช้เป็นตัวกรองหรือตัวยืนยันสัญญาณ Choch/BoS (Change of Character / Break of Structure)
1. ภาพรวมอินดิเคเตอร์ (Overall Purpose)
อินดิเคเตอร์นี้มีจุดประสงค์หลักคือ:
ระบุโครงสร้างตลาด: ตีเส้นและป้ายกำกับ Choch (Change of Character) และ BoS (Break of Structure) บนกราฟโดยอัตโนมัติ
ผสานการยืนยันด้วย MACD: สัญญาณ Choch/BoS จะถูกพิจารณาก็ต่อเมื่อ MACD Histogram เกิดการตัดขึ้นหรือลง (Zero Cross) ในทิศทางที่สอดคล้องกัน
แสดง Fair Value Gap (FVG): หากเปิดใช้งาน จะมีการตีกล่อง FVG บนกราฟ
แสดงระดับ Fibonacci: คำนวณและแสดงระดับ Fibonacci ที่สำคัญตามโครงสร้างตลาดปัจจุบัน
ปรับตาม Timeframe: การคำนวณและการแสดงผลทั้งหมดจะปรับตาม Timeframe ที่คุณกำลังใช้งานอยู่โดยอัตโนมัติ
2. ส่วนประกอบหลักของโค้ด (Code Breakdown)
โค้ดนี้สามารถแบ่งออกเป็นส่วนหลัก ๆ ได้ดังนี้:
2.1 Inputs (การตั้งค่า)
ส่วนนี้คือตัวแปรที่คุณสามารถปรับแต่งได้ในหน้าต่างการตั้งค่าของอินดิเคเตอร์ (คลิกที่รูปฟันเฟืองข้างชื่ออินดิเคเตอร์บนกราฟ)
MACD Settings (ตั้งค่า MACD):
fast_len: ความยาวของ Fast EMA สำหรับ MACD (ค่าเริ่มต้น 12)
slow_len: ความยาวของ Slow EMA สำหรับ MACD (ค่าเริ่มต้น 26)
signal_len: ความยาวของ Signal Line สำหรับ MACD (ค่าเริ่มต้น 9)
= ta.macd(close, fast_len, slow_len, signal_len): คำนวณค่า MACD Line, Signal Line และ Histogram โดยใช้ราคาปิด (close) และค่าความยาวที่กำหนด
is_bullish_macd_cross: ตรวจสอบว่า MACD Histogram ตัดขึ้นเหนือเส้น 0 (จากค่าลบเป็นบวก)
is_bearish_macd_cross: ตรวจสอบว่า MACD Histogram ตัดลงใต้เส้น 0 (จากค่าบวกเป็นลบ)
Fear Value Gap (FVG) Settings:
isFvgToShow: (Boolean) เปิด/ปิดการแสดง FVG บนกราฟ
bullishFvgColor: สีสำหรับ Bullish FVG
bearishFvgColor: สีสำหรับ Bearish FVG
mitigatedFvgColor: สีสำหรับ FVG ที่ถูก Mitigate (ลดทอน) แล้ว
fvgHistoryNbr: จำนวน FVG ย้อนหลังที่จะแสดง
isMitigatedFvgToReduce: (Boolean) เปิด/ปิดการลดขนาด FVG เมื่อถูก Mitigate
Structures (โครงสร้างตลาด) Settings:
isStructBodyCandleBreak: (Boolean) หากเป็น true การ Break จะต้องเกิดขึ้นด้วย เนื้อเทียน ที่ปิดเหนือ/ใต้ Swing High/Low หากเป็น false แค่ไส้เทียนทะลุก็ถือว่า Break
isCurrentStructToShow: (Boolean) เปิด/ปิดการแสดงเส้นโครงสร้างตลาดปัจจุบัน (เส้นสีน้ำเงินในภาพตัวอย่าง)
pivot_len: ความยาวของแท่งเทียนที่ใช้ในการมองหาจุด Pivot (Swing High/Low) ยิ่งค่าน้อยยิ่งจับ Swing เล็กๆ ได้, ยิ่งค่ามากยิ่งจับ Swing ใหญ่ๆ ได้
bullishBosColor, bearishBosColor: สีสำหรับเส้นและป้าย BOS ขาขึ้น/ขาลง
bosLineStyleOption, bosLineWidth: สไตล์ (Solid, Dotted, Dashed) และความหนาของเส้น BOS
bullishChochColor, bearishChochColor: สีสำหรับเส้นและป้าย CHoCH ขาขึ้น/ขาลง
chochLineStyleOption, chochLineWidth: สไตล์ (Solid, Dotted, Dashed) และความหนาของเส้น CHoCH
currentStructColor, currentStructLineStyleOption, currentStructLineWidth: สี, สไตล์ และความหนาของเส้นโครงสร้างตลาดปัจจุบัน
structHistoryNbr: จำนวนการ Break (Choch/BoS) ย้อนหลังที่จะแสดง
Structure Fibonacci (จากโค้ดต้นฉบับ):
เป็นชุด Input สำหรับเปิด/ปิด, กำหนดค่า, สี, สไตล์ และความหนาของเส้น Fibonacci Levels ต่างๆ (0.786, 0.705, 0.618, 0.5, 0.382) ที่จะถูกคำนวณจากโครงสร้างตลาดปัจจุบัน
2.2 Helper Functions (ฟังก์ชันช่วยทำงาน)
getLineStyle(lineOption): ฟังก์ชันนี้ใช้แปลงค่า String ที่เลือกจาก Input (เช่น "─", "┈", "╌") ให้เป็นรูปแบบ line.style_ ที่ Pine Script เข้าใจ
get_structure_highest_bar(lookback): ฟังก์ชันนี้พยายามหา Bar Index ของแท่งเทียนที่ทำ Swing High ภายในช่วง lookback ที่กำหนด
get_structure_lowest_bar(lookback): ฟังก์ชันนี้พยายามหา Bar Index ของแท่งเทียนที่ทำ Swing Low ภายในช่วง lookback ที่กำหนด
is_structure_high_broken(...): ฟังก์ชันนี้ตรวจสอบว่าราคาปัจจุบันได้ Break เหนือ _structureHigh (Swing High) หรือไม่ โดยพิจารณาจาก _highStructBreakPrice (ราคาปิดหรือราคา High ขึ้นอยู่กับการตั้งค่า isStructBodyCandleBreak)
FVGDraw(...): ฟังก์ชันนี้รับ Arrays ของ FVG Boxes, Types, Mitigation Status และ Labels มาประมวลผล เพื่ออัปเดตสถานะของ FVG (เช่น ถูก Mitigate หรือไม่) และปรับขนาด/ตำแหน่งของ FVG Box และ Label บนกราฟ
2.3 Global Variables (ตัวแปรทั่วทั้งอินดิเคเตอร์)
เป็นตัวแปรที่ประกาศด้วย var ซึ่งหมายความว่าค่าของมันจะถูกเก็บไว้และอัปเดตในแต่ละแท่งเทียน (persists across bars)
structureLines, structureLabels: Arrays สำหรับเก็บอ็อบเจกต์ line และ label ของเส้น Choch/BoS ที่วาดบนกราฟ
fvgBoxes, fvgTypes, fvgLabels, isFvgMitigated: Arrays สำหรับเก็บข้อมูลของ FVG Boxes และสถานะต่างๆ
structureHigh, structureLow: เก็บราคาของ Swing High/Low ที่สำคัญของโครงสร้างตลาดปัจจุบัน
structureHighStartIndex, structureLowStartIndex: เก็บ Bar Index ของจุดเริ่มต้นของ Swing High/Low ที่สำคัญ
structureDirection: เก็บสถานะของทิศทางโครงสร้างตลาด (1 = Bullish, 2 = Bearish, 0 = Undefined)
fiboXPrice, fiboXStartIndex, fiboXLine, fiboXLabel: ตัวแปรสำหรับเก็บข้อมูลและอ็อบเจกต์ของเส้น Fibonacci Levels
isBOSAlert, isCHOCHAlert: (Boolean) ใช้สำหรับส่งสัญญาณ Alert (หากมีการตั้งค่า Alert ไว้)
2.4 FVG Processing (การประมวลผล FVG)
ส่วนนี้จะตรวจสอบเงื่อนไขการเกิด FVG (Bullish FVG: high < low , Bearish FVG: low > high )
หากเกิด FVG และ isFvgToShow เป็น true จะมีการสร้าง box และ label ใหม่เพื่อแสดง FVG บนกราฟ
มีการจัดการ fvgBoxes และ fvgLabels เพื่อจำกัดจำนวน FVG ที่แสดงตาม fvgHistoryNbr และลบ FVG เก่าออก
ฟังก์ชัน FVGDraw จะถูกเรียกเพื่ออัปเดตสถานะของ FVG (เช่น การถูก Mitigate) และปรับการแสดงผล
2.5 Structures Processing (การประมวลผลโครงสร้างตลาด)
Initialization: ที่ bar_index == 0 (แท่งเทียนแรกของกราฟ) จะมีการกำหนดค่าเริ่มต้นให้กับ structureHigh, structureLow, structureHighStartIndex, structureLowStartIndex
Finding Current High/Low: highest, highestBar, lowest, lowestBar ถูกใช้เพื่อหา High/Low ที่สุดและ Bar Index ของมันใน 10 แท่งล่าสุด (หรือทั้งหมดหากกราฟสั้นกว่า 10 แท่ง)
Calculating Structure Max/Min Bar: structureMaxBar และ structureMinBar ใช้ฟังก์ชัน get_structure_highest_bar และ get_structure_lowest_bar เพื่อหา Bar Index ของ Swing High/Low ที่แท้จริง (ไม่ใช่แค่ High/Low ที่สุดใน lookback แต่เป็นจุด Pivot ที่สมบูรณ์)
Break Price: lowStructBreakPrice และ highStructBreakPrice จะเป็นราคาปิด (close) หรือราคา Low/High ขึ้นอยู่กับ isStructBodyCandleBreak
isStuctureLowBroken / isStructureHighBroken: เงื่อนไขเหล่านี้ตรวจสอบว่าราคาได้ทำลาย structureLow หรือ structureHigh หรือไม่ โดยพิจารณาจากราคา Break, ราคาแท่งก่อนหน้า และ Bar Index ของจุดเริ่มต้นโครงสร้าง
Choch/BoS Logic (ส่วนสำคัญที่ถูกผสานกับ MACD):
if(isStuctureLowBroken and is_bearish_macd_cross): นี่คือจุดที่ MACD เข้ามามีบทบาท หากราคาทำลาย structureLow (สัญญาณขาลง) และ MACD Histogram เกิด Bearish Zero Cross (is_bearish_macd_cross เป็น true) อินดิเคเตอร์จะพิจารณาว่าเป็น Choch หรือ BoS
หาก structureDirection == 1 (เดิมเป็นขาขึ้น) หรือ 0 (ยังไม่กำหนด) จะตีเป็น "CHoCH" (เปลี่ยนทิศทางโครงสร้างเป็นขาลง)
หาก structureDirection == 2 (เดิมเป็นขาลง) จะตีเป็น "BOS" (ยืนยันโครงสร้างขาลง)
มีการสร้าง line.new และ label.new เพื่อวาดเส้นและป้ายกำกับ
structureDirection จะถูกอัปเดตเป็น 1 (Bullish)
structureHighStartIndex, structureLowStartIndex, structureHigh, structureLow จะถูกอัปเดตเพื่อกำหนดโครงสร้างใหม่
else if(isStructureHighBroken and is_bullish_macd_cross): เช่นกันสำหรับขาขึ้น หากราคาทำลาย structureHigh (สัญญาณขาขึ้น) และ MACD Histogram เกิด Bullish Zero Cross (is_bullish_macd_cross เป็น true) อินดิเคเตอร์จะพิจารณาว่าเป็น Choch หรือ BoS
หาก structureDirection == 2 (เดิมเป็นขาลง) หรือ 0 (ยังไม่กำหนด) จะตีเป็น "CHoCH" (เปลี่ยนทิศทางโครงสร้างเป็นขาขึ้น)
หาก structureDirection == 1 (เดิมเป็นขาขึ้น) จะตีเป็น "BOS" (ยืนยันโครงสร้างขาขึ้น)
มีการสร้าง line.new และ label.new เพื่อวาดเส้นและป้ายกำกับ
structureDirection จะถูกอัปเดตเป็น 2 (Bearish)
structureHighStartIndex, structureLowStartIndex, structureHigh, structureLow จะถูกอัปเดตเพื่อกำหนดโครงสร้างใหม่
การลบเส้นเก่า: d.delete_line (หากไลบรารีทำงาน) จะถูกเรียกเพื่อลบเส้นและป้ายกำกับเก่าออกเมื่อจำนวนเกิน structHistoryNbr
Updating Structure High/Low (else block): หากไม่มีการ Break เกิดขึ้น แต่ราคาปัจจุบันสูงกว่า structureHigh หรือต่ำกว่า structureLow ในทิศทางที่สอดคล้องกัน (เช่น ยังคงเป็นขาขึ้นและทำ High ใหม่) structureHigh หรือ structureLow จะถูกอัปเดตเพื่อติดตาม High/Low ที่สุดของโครงสร้างปัจจุบัน
Current Structure Display:
หาก isCurrentStructToShow เป็น true อินดิเคเตอร์จะวาดเส้น structureHighLine และ structureLowLine เพื่อแสดงขอบเขตของโครงสร้างตลาดปัจจุบัน
Fibonacci Display:
หาก isFiboXToShow เป็น true อินดิเคเตอร์จะคำนวณและวาดเส้น Fibonacci Levels ต่างๆ (0.786, 0.705, 0.618, 0.5, 0.382) โดยอิงจาก structureHigh และ structureLow ของโครงสร้างตลาดปัจจุบัน
Alerts:
alertcondition: ใช้สำหรับตั้งค่า Alert ใน TradingView เมื่อเกิดสัญญาณ BOS หรือ CHOCH
plot(na):
plot(na) เป็นคำสั่งที่สำคัญในอินดิเคเตอร์ที่ไม่ได้ต้องการพล็อต Series ของข้อมูลบนกราฟ (เช่น ไม่ได้พล็อตเส้น EMA หรือ RSI) แต่ใช้วาดอ็อบเจกต์ (Line, Label, Box) โดยตรง
การมี plot(na) ช่วยให้ Pine Script รู้ว่าอินดิเคเตอร์นี้มีเอาต์พุตที่แสดงผลบนกราฟ แม้ว่าจะไม่ได้เป็น Series ที่พล็อตตามปกติก็ตาม
3. วิธีใช้งาน
คัดลอกโค้ดทั้งหมด ที่อยู่ในบล็อก immersive ด้านบน
ไปที่ TradingView และเปิดกราฟที่คุณต้องการ
คลิกที่เมนู "Pine Editor" ที่อยู่ด้านล่างของหน้าจอ
ลบโค้ดเดิมที่มีอยู่ และ วางโค้ดที่คัดลอกมา ลงไปแทน
คลิกที่ปุ่ม "Add to Chart"
อินดิเคเตอร์จะถูกเพิ่มลงในกราฟของคุณโดยอัตโนมัติ คุณสามารถคลิกที่รูปฟันเฟืองข้างชื่ออินดิเคเตอร์บนกราฟเพื่อเข้าถึงหน้าต่างการตั้งค่าและปรับแต่งตามความต้องการของคุณได้
Hello! I will explain the "SMC Structures and FVG + MACD" indicator you provided in detail, section by section, so you can fully understand how it works.This indicator combines the concepts of Smart Money Concept (SMC), which focuses on analyzing Market Structure and Fair Value Gaps (FVG), with the MACD indicator to serve as a filter or confirmation for Choch (Change of Character) and BoS (Break of Structure) signals.1. Overall PurposeThe main purposes of this indicator are:Identify Market Structure: Automatically draw lines and label Choch (Change of Character) and BoS (Break of Structure) on the chart.Integrate MACD Confirmation: Choch/BoS signals will only be considered when the MACD Histogram performs a cross (Zero Cross) in the corresponding direction.Display Fair Value Gap (FVG): If enabled, FVG boxes will be drawn on the chart.Display Fibonacci Levels: Calculate and display important Fibonacci levels based on the current market structure.Adapt to Timeframe: All calculations and displays will automatically adjust to the timeframe you are currently using.2. Code BreakdownThis code can be divided into the following main sections:2.1 Inputs (Settings)This section contains variables that you can adjust in the indicator's settings window (click the gear icon next to the indicator's name on the chart).MACD Settings:fast_len: Length of the Fast EMA for MACD (default 12)slow_len: Length of the Slow EMA for MACD (default 26)signal_len: Length of the Signal Line for MACD (default 9) = ta.macd(close, fast_len, slow_len, signal_len): Calculates the MACD Line, Signal Line, and Histogram using the closing price (close) and the specified lengths.is_bullish_macd_cross: Checks if the MACD Histogram crosses above the 0 line (from negative to positive).is_bearish_macd_cross: Checks if the MACD Histogram crosses below the 0 line (from positive to negative).Fear Value Gap (FVG) Settings:isFvgToShow: (Boolean) Enables/disables the display of FVG on the chart.bullishFvgColor: Color for Bullish FVG.bearishFvgColor: Color for Bearish FVG.mitigatedFvgColor: Color for FVG that has been mitigated.fvgHistoryNbr: Number of historical FVG to display.isMitigatedFvgToReduce: (Boolean) Enables/disables reducing the size of FVG when mitigated.Structures (โครงสร้างตลาด) Settings:isStructBodyCandleBreak: (Boolean) If true, the break must occur with the candle body closing above/below the Swing High/Low. If false, a wick break is sufficient.isCurrentStructToShow: (Boolean) Enables/disables the display of the current market structure lines (blue lines in the example image).pivot_len: Lookback length for identifying Pivot points (Swing High/Low). A smaller value captures smaller, more frequent swings; a larger value captures larger, more significant swings.bullishBosColor, bearishBosColor: Colors for bullish/bearish BOS lines and labels.bosLineStyleOption, bosLineWidth: Style (Solid, Dotted, Dashed) and width of BOS lines.bullishChochColor, bearishChochColor: Colors for bullish/bearish CHoCH lines and labels.chochLineStyleOption, chochLineWidth: Style (Solid, Dotted, Dashed) and width of CHoCH lines.currentStructColor, currentStructLineStyleOption, currentStructLineWidth: Color, style, and width of the current market structure lines.structHistoryNbr: Number of historical breaks (Choch/BoS) to display.Structure Fibonacci (from original code):A set of inputs to enable/disable, define values, colors, styles, and widths for various Fibonacci Levels (0.786, 0.705, 0.618, 0.5, 0.382) that will be calculated from the current market structure.2.2 Helper FunctionsgetLineStyle(lineOption): This function converts the selected string input (e.g., "─", "┈", "╌") into a line.style_ format understood by Pine Script.get_structure_highest_bar(lookback): This function attempts to find the Bar Index of the Swing High within the specified lookback period.get_structure_lowest_bar(lookback): This function attempts to find the Bar Index of the Swing Low within the specified lookback period.is_structure_high_broken(...): This function checks if the current price has broken above _structureHigh (Swing High), considering _highStructBreakPrice (closing price or high price depending on isStructBodyCandleBreak setting).FVGDraw(...): This function takes arrays of FVG Boxes, Types, Mitigation Status, and Labels to process and update the status of FVG (e.g., whether it's mitigated) and adjust the size/position of FVG Boxes and Labels on the chart.2.3 Global VariablesThese are variables declared with var, meaning their values are stored and updated on each bar (persists across bars).structureLines, structureLabels: Arrays to store line and label objects for Choch/BoS lines drawn on the chart.fvgBoxes, fvgTypes, fvgLabels, isFvgMitigated: Arrays to store FVG box data and their respective statuses.structureHigh, structureLow: Stores the price of the significant Swing High/Low of the current market structure.structureHighStartIndex, structureLowStartIndex: Stores the Bar Index of the start point of the significant Swing High/Low.structureDirection: Stores the status of the market structure direction (1 = Bullish, 2 = Bearish, 0 = Undefined).fiboXPrice, fiboXStartIndex, fiboXLine, fiboXLabel: Variables to store data and objects for Fibonacci Levels.isBOSAlert, isCHOCHAlert: (Boolean) Used to trigger alerts in TradingView (if alerts are configured).2.4 FVG ProcessingThis section checks the conditions for FVG formation (Bullish FVG: high < low , Bearish FVG: low > high ).If FVG occurs and isFvgToShow is true, a new box and label are created to display the FVG on the chart.fvgBoxes and fvgLabels are managed to limit the number of FVG displayed according to fvgHistoryNbr and remove older FVG.The FVGDraw function is called to update the FVG status (e.g., whether it's mitigated) and adjust its display.2.5 Structures ProcessingInitialization: At bar_index == 0 (the first bar of the chart), structureHigh, structureLow, structureHighStartIndex, and structureLowStartIndex are initialized.Finding Current High/Low: highest, highestBar, lowest, lowestBar are used to find the highest/lowest price and its Bar Index of it in the last 10 bars (or all bars if the chart is shorter than 10 bars).Calculating Structure Max/Min Bar: structureMaxBar and structureMinBar use get_structure_highest_bar and get_structure_lowest_bar functions to find the Bar Index of the true Swing High/Low (not just the highest/lowest in the lookback but a complete Pivot point).Break Price: lowStructBreakPrice and highStructBreakPrice will be the closing price (close) or the Low/High price, depending on the isStructBodyCandleBreak setting.isStuctureLowBroken / isStructureHighBroken: These conditions check if the price has broken structureLow or structureHigh, considering the break price, previous bar prices, and the Bar Index of the structure's starting point.Choch/BoS Logic (Key Integration with MACD):if(isStuctureLowBroken and is_bearish_macd_cross): This is where MACD plays a role. If the price breaks structureLow (bearish signal) AND the MACD Histogram performs a Bearish Zero Cross (is_bearish_macd_cross is true), the indicator will consider it a Choch or BoS.If structureDirection == 1 (previously bullish) or 0 (undefined), it will be labeled "CHoCH" (changing structure direction to bearish).If structureDirection == 2 (already bearish), it will be labeled "BOS" (confirming bearish structure).line.new and label.new are used to draw the line and label.structureDirection will be updated to 1 (Bullish).structureHighStartIndex, structureLowStartIndex, structureHigh, structureLow will be updated to define the new structure.else if(isStructureHighBroken and is_bullish_macd_cross): Similarly for bullish breaks. If the price breaks structureHigh (bullish signal) AND the MACD Histogram performs a Bullish Zero Cross (is_bullish_macd_cross is true), the indicator will consider it a Choch or BoS.If structureDirection == 2 (previously bearish) or 0 (undefined), it will be labeled "CHoCH" (changing structure direction to bullish).If structureDirection == 1 (already bullish), it will be labeled "BOS" (confirming bullish structure).line.new and label.new are used to draw the line and label.structureDirection will be updated to 2 (Bearish).structureHighStartIndex, structureLowStartIndex, structureHigh, structureLow will be updated to define the new structure.Deleting Old Lines: d.delete_line (if the library works) will be called to delete old lines and labels when their number exceeds structHistoryNbr.Updating Structure High/Low (else block): If no break occurs, but the current price is higher than structureHigh or lower than structureLow in the corresponding direction (e.g., still bullish and making a new high), structureHigh or structureLow will be updated to track the highest/lowest point of the current structure.Current Structure Display:If isCurrentStructToShow is true, the indicator draws structureHighLine and structureLowLine to show the boundaries of the current market structure.Fibonacci Display:If isFiboXToShow is true, the indicator calculates and draws various Fibonacci Levels (0.786, 0.705, 0.618, 0.5, 0.382) based on the structureHigh and structureLow of the current market structure.Alerts:alertcondition: Used to set up alerts in TradingView when BOS or CHOCH signals occur.plot(na):plot(na) is an important statement in indicators that do not plot data series directly on the chart (e.g., not plotting EMA or RSI lines) but instead draw objects (Line, Label, Box).Having plot(na) helps Pine Script recognize that this indicator has an output displayed on the chart, even if it's not a regularly plotted series.3. How to UseCopy all the code in the immersive block above.Go to TradingView and open your desired chart.Click on the "Pine Editor" menu at the bottom of the screen.Delete any existing code and paste the copied code in its place.Click the "Add to Chart" button.The indicator will be added to your chart automatically. You can click the gear icon next to the indicator's name on the chart to access the settings window and customize it to your needs.I hope this explanation helps you understand this indicator in detail. If anything is unclear, or you need further adjustments, please let me know.
Parallel Projections [theEccentricTrader]█ OVERVIEW
This indicator automatically projects parallel trendlines or channels, from a single point of origin. In the example above I have applied the indicator twice to the 1D SPXUSD. The five upper lines (green) are projected at an angle of -5 from the 1-month swing high anchor point with a projection ratio of -72. And the seven lower lines (blue) are projected at an angle of 10 with a projection ratio of 36 from the 1-week swing low anchor point.
█ CONCEPTS
Green and Red Candles
• A green candle is one that closes with a high price equal to or above the price it opened.
• A red candle is one that closes with a low price that is lower than the price it opened.
Swing Highs and Swing Lows
• A swing high is a green candle or series of consecutive green candles followed by a single red candle to complete the swing and form the peak.
• A swing low is a red candle or series of consecutive red candles followed by a single green candle to complete the swing and form the trough.
Peak and Trough Prices (Basic)
• The peak price of a complete swing high is the high price of either the red candle that completes the swing high or the high price of the preceding green candle, depending on which is higher.
• The trough price of a complete swing low is the low price of either the green candle that completes the swing low or the low price of the preceding red candle, depending on which is lower.
Historic Peaks and Troughs
The current, or most recent, peak and trough occurrences are referred to as occurrence zero. Previous peak and trough occurrences are referred to as historic and ordered numerically from right to left, with the most recent historic peak and trough occurrences being occurrence one.
Support and Resistance
• Support refers to a price level where the demand for an asset is strong enough to prevent the price from falling further.
• Resistance refers to a price level where the supply of an asset is strong enough to prevent the price from rising further.
Support and resistance levels are important because they can help traders identify where the price of an asset might pause or reverse its direction, offering potential entry and exit points. For example, a trader might look to buy an asset when it approaches a support level , with the expectation that the price will bounce back up. Alternatively, a trader might look to sell an asset when it approaches a resistance level , with the expectation that the price will drop back down.
It's important to note that support and resistance levels are not always relevant, and the price of an asset can also break through these levels and continue moving in the same direction.
Trendlines
Trendlines are straight lines that are drawn between two or more points on a price chart. These lines are used as dynamic support and resistance levels for making strategic decisions and predictions about future price movements. For example traders will look for price movements along, and reactions to, trendlines in the form of rejections or breakouts/downs.
█ FEATURES
Inputs
• Anchor Point Type
• Swing High/Low Occurrence
• HTF Resolution
• Highest High/Lowest Low Lookback
• Angle Degree
• Projection Ratio
• Number Lines
• Line Color
Anchor Point Types
• Swing High
• Swing Low
• Swing High (HTF)
• Swing Low (HTF)
• Highest High
• Lowest Low
• Intraday Highest High (intraday charts only)
• Intraday Lowest Low (intraday charts only)
Swing High/Swing Low Occurrence
This input is used to determine which historic peak or trough to reference for swing high or swing low anchor point types.
HTF Resolution
This input is used to determine which higher timeframe to reference for swing high (HTF) or swing low (HTF) anchor point types.
Highest High/Lowest Low Lookback
This input is used to determine the lookback length for highest high or lowest low anchor point types.
Intraday Highest High/Lowest Low Lookback
When using intraday highest high or lowest low anchor point types, the lookback length is calculated automatically based on number of bars since the daily candle opened.
Angle Degree
This input is used to determine the angle of the trendlines. The output is expressed in terms of point or pips, depending on the symbol type, which is then passed through the built in math.todegrees() function. Positive numbers will project the lines upwards while negative numbers will project the lines downwards. Depending on the market and timeframe, the impact input values will have on the visible gaps between the lines will vary greatly. For example, an input of 10 will have a far greater impact on the gaps between the lines when viewed from the 1-minute timeframe than it would on the 1-day timeframe. The input is a float and as such the value passed through can go into as many decimal places as the user requires.
It is also worth mentioning that as more lines are added the gaps between the lines, that are closest to the anchor point, will get tighter as they make their way up the y-axis. Although the gaps between the lines will stay constant at the x2 plot, i.e. a distance of 10 points between them, they will gradually get tighter and tighter at the point of origin as the slope of the lines get steeper.
Projection Ratio
This input is used to determine the distance between the parallels, expressed in terms of point or pips. Positive numbers will project the lines upwards while negative numbers will project the lines downwards. Depending on the market and timeframe, the impact input values will have on the visible gaps between the lines will vary greatly. For example, an input of 10 will have a far greater impact on the gaps between the lines when viewed from the 1-minute timeframe than it would on the 1-day timeframe. The input is a float and as such the value passed through can go into as many decimal places as the user requires.
Number Lines
This input is used to determine the number of lines to be drawn on the chart, maximum is 500.
█ LIMITATIONS
All green and red candle calculations are based on differences between open and close prices, as such I have made no attempt to account for green candles that gap lower and close below the close price of the preceding candle, or red candles that gap higher and close above the close price of the preceding candle. This may cause some unexpected behaviour on some markets and timeframes. I can only recommend using 24-hour markets, if and where possible, as there are far fewer gaps and, generally, more data to work with.
If the lines do not draw or you see a study error saying that the script references too many candles in history, this is most likely because the higher timeframe anchor point is not present on the current timeframe. This problem usually occurs when referencing a higher timeframe, such as the 1-month, from a much lower timeframe, such as the 1-minute. How far you can lookback for higher timeframe anchor points on the current timeframe will also be limited by your Trading View subscription plan. Premium users get 20,000 candles worth of data, pro+ and pro users get 10,000, and basic users get 5,000.
█ RAMBLINGS
It is my current thesis that the indicator will work best when used in conjunction with my Wavemeter indicator, which can be used to set the angle and projection ratio. For example, the average wave height or amplitude could be used as the value for the angle and projection ratio inputs. Or some factor or multiple of such an average. I think this makes sense as it allows for objectivity when applying the indicator across different markets and timeframes with different energies and vibrations.
“If you want to find the secrets of the universe, think in terms of energy, frequency and vibration.”
― Nikola Tesla